//
//  XBCover.m
//  微博
//
//  Created by Clement_Gu on 16/4/21.
//  Copyright © 2016年 小白. All rights reserved.
//

#import "XBCover.h"
#import "Pre.pch"
@implementation XBCover
//设置浅灰色蒙版
-(void)setDimBackground:(BOOL)dimBackground
{
    _dimBackground = dimBackground;
    if (dimBackground) {
        self.backgroundColor = [UIColor blackColor];
        self.alpha = 0.5;
        
    }
    else
    {
        self.alpha = 1;
        self.backgroundColor = [UIColor clearColor];
    }
    
}
//显示蒙板
+(instancetype)show
{
    //初始化界面
    XBCover *cover = [[XBCover alloc]initWithFrame:[UIScreen mainScreen].bounds];
    //背景色
    cover.backgroundColor = [UIColor clearColor];
    //uiapplication keywindow
    [XBKeyWindow addSubview:cover];
    return cover;
}
//点击蒙版时候做的事情
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    //移除蒙版
    [self removeFromSuperview];
    
    //通知代理移除菜单 判断某个类或实例是否能处理某个方法 如果能处理 则执行
    if([self.delegate respondsToSelector:@selector(coverDidClickCover:)])
    {
        [self.delegate coverDidClickCover:self];
    
    }

}



@end
